<?php

namespace App\Models;



class Comment extends Base
{
    const TYPE_WORK = 1;
    const TYPE_MATERIAL = 2;
    const TYPE_SERVICE = 3;

    protected $fillable = ['user_id', 'entity_id', 'type', 'parent_id', 'reply_to_id', 'reply_count', 'message', 'refer_message', 'refer_user_id'];

    public function child() {
        return $this->hasMany(Comment::class, 'parent_id');
    }

    public function reply() {
        return $this->belongsTo(Comment::class, 'reply_to_id');
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function order() {
        return $this->belongsTo(Order::class, 'order_id');
    }

    public function refer_user() {
        return $this->belongsTo(User::class, 'refer_user_id');
    }
}
